﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.ETL.Domain
{
    /// <summary>
    /// 0xfe0000-0xfeffff
    /// </summary>
    class ErrorCode
    {
        private static Hashtable s_comments = new Hashtable();

        public const int COM_NoError = 0x0000;
        public const int COM_DBError = 0x0001;
        public const int COM_InvalidParameter = 0x0006;
        public const int COM_Exception = 0x0007;
        public const int DtSerTypeNotFound = 0x0002;
        public const int DtSerManagerNotFound = 0x0003;
        

        public const int DtSerProxyNotFound = 0x0004;
        public const int DtSerHasTask = 0x0005;

        public const int EntityNotFound = 0x0008;
        public const int NoColumnMapping = 0x0009;
        public const int InvalidColumnMapping = 0x0010;
        public const int COM_OBJExist = 0x0011;
        public const int COM_OBJNotExist = 0x0012;
        public const int InvalidAccount = 0x0013;
        public const int InvalidPassword = 0x0014;
        public const int COM_CodeExist = 0x0015;
        public const int COM_CodeNotExist = 0x0016;
        public const int COM_ParentExist = 0x0017;
        public const int COM_ParentNotExist = 0x0018;
        public const int COM_FolderHasChildren = 0x0019;
        public const int COM_FolderHasService = 0x001A;
        public const int NoMappintDtTable = 0x001B;
        public const int TaskIsFinished = 0x001C;
        public const int TaskNoUnfinishedRecord = 0x001D;
        public const int TaskHasUnfinishedRecord = 0x001E;
        public const int AppNotAuthorizated = 0x001F;
        public const int RawDataTableNotExist = 0x0020;
        public const int InvalidColumnSettings = 0x0021;
        public const int InvalidParameterSettings = 0x0022;
        public const int DtTable_NameExist = 0x0023;
        public const int DtTable_InvalidColumnSettings = 0x0024;
        public const int DtSource_InvalidParameterSettings = 0x0025;
        public const int DtTable_HasMapped = 0x0026;
        public const int Batch_NotExist = 0x0027;
        public const int DVPlugIn_NoPlugIn = 0x0028;
        public const int DVPlugIn_InvalidPlugInSettings = 0x0029;
        public const int DtSource_DataIsNull = 0x002A;
        public const int PubDataSource_ErrorParameterSettings = 0x002B;

        public const int DtSource_NotMappingDtTable = 0x002C;
        public const int Service_IsNotRDS = 0x002D;
        public const int Task_EventIsExist = 0x002E;
        public const int EXTDS_NoType = 0x002F;
        public const int DtSer_NameExist = 0x0030;
        public const int DtSer_AddressExist = 0x0031;
        public const int DtTable_IsNotRawDataTable = 0x0032;
        public const int DtTable_PKCannotChange = 0x0033;

        /// <summary>
        /// 参数转换失败
        /// </summary>
        public const int RTParameter_ConvertFailure = 0x0034;
        public const int RTParameter_InvaliedFormat = 0x0035;
        public const int DtSource_HasMappinged = 0x0036;
        public const int DtTable_HasMultipleMapping = 0x0037;


        public const int EXTDS_Error = 0x0038;

        static ErrorCode()
        {
            s_comments.Add(COM_NoError, "操作成功");
            s_comments.Add(COM_DBError, "数据库错误");
            s_comments.Add(COM_InvalidParameter, "参数错误");
            s_comments.Add(COM_Exception, "出现了异常");
            s_comments.Add(DtSerTypeNotFound, "未知的数据服务类型");
            s_comments.Add(DtSerManagerNotFound, "数据服务管理对象未发现");
            s_comments.Add(DtSerProxyNotFound, "数据服务代理对象未发现");
            s_comments.Add(DtSerHasTask, "数据服务已存在任务");
            s_comments.Add(EntityNotFound, "实体对象不存在");
            s_comments.Add(NoColumnMapping, "没有数据列的定义");
            s_comments.Add(InvalidColumnMapping, "错误的数据列定义");
            s_comments.Add(COM_OBJExist, "对象已存在");
            s_comments.Add(COM_OBJNotExist, "对象不存在");
            s_comments.Add(InvalidAccount, "无效的账号");
            s_comments.Add(InvalidPassword, "无效的密码");
            s_comments.Add(COM_CodeExist, "编号已存在");
            s_comments.Add(COM_CodeNotExist, "编号不存在");
            s_comments.Add(COM_ParentExist, "父节点已存在");
            s_comments.Add(COM_ParentNotExist, "父节点不存在");
            s_comments.Add(COM_FolderHasChildren, "拥有子目录");
            s_comments.Add(COM_FolderHasService, "拥有数据服务");
            s_comments.Add(NoMappintDtTable, "没有映射数据表");
            s_comments.Add(TaskIsFinished, "任务已经执行完成");
            s_comments.Add(TaskNoUnfinishedRecord, "任务没有未完成记录");
            s_comments.Add(TaskHasUnfinishedRecord, "任务还有未完成记录");
            s_comments.Add(AppNotAuthorizated, "应用程序没有授权");
            s_comments.Add(RawDataTableNotExist, "原始数据表不存在");
            s_comments.Add(InvalidColumnSettings, "无效的列设置[name,type,description,name,type,description]");
            s_comments.Add(InvalidParameterSettings, "无效的参数设置[name,type,description,name,type,description]");
            s_comments.Add(DtTable_NameExist, "数据表名称已存在");
            s_comments.Add(DtTable_InvalidColumnSettings, "无效的数据列设置[name,type,length,nullable,description,...]");
            s_comments.Add(DtSource_InvalidParameterSettings, "无效的数据源参数设置[name,type,description,...]");
            s_comments.Add(DtTable_HasMapped, "数据表已经存在数据源映射关系");
            s_comments.Add(Batch_NotExist, "批次不存在");
            s_comments.Add(DVPlugIn_NoPlugIn, "没有发现插件");
            s_comments.Add(DVPlugIn_InvalidPlugInSettings, "无效的数据审核插件配置");
            s_comments.Add(DtSource_DataIsNull, "没有获取到数据");
            s_comments.Add(PubDataSource_ErrorParameterSettings, "错误的参数配置");

            s_comments.Add(DtSource_NotMappingDtTable, "数据源没有映射数据表");

            s_comments.Add(Service_IsNotRDS, "数据服务不是原始数据服务");
            s_comments.Add(Task_EventIsExist, "任务事件名称已经存在");
            s_comments.Add(EXTDS_NoType, "不存在外部扩展服务类型");

            s_comments.Add(DtSer_NameExist, "数据服务名称以存在");
            s_comments.Add(DtSer_AddressExist, "数据服务地址以存在");
            s_comments.Add(DtTable_IsNotRawDataTable, "不是原始数据表");
            s_comments.Add(DtTable_PKCannotChange, "主键无法修改");

            s_comments.Add(RTParameter_ConvertFailure, "参数转换成实际值失败");
            s_comments.Add(RTParameter_InvaliedFormat, "参数值的格式不正确");
            s_comments.Add(DtSource_HasMappinged, "数据源已经映射了数据表");
            s_comments.Add(DtTable_HasMultipleMapping, "数据表映射了多个数据源");
        }

        public static string String(int code)
        {
            return ((string)s_comments[code]);
        }
    }
}
